@include scrollbar();

:focus-visible {
    outline-color: var(--primaryColor);
    outline-style: solid;
}

html,
body {
    line-height: var(--baseLineHeight);
    font-family: var(--baseFontFamily);
    font-size: var(--baseFontSize);
    color: var(--txtPrimaryColor);
    background: var(--bodyColor);
}

#app {
    overflow: auto;
    display: block;
    width: 100%;
    height: 100vh;
}

%block {
    display: block;
    width: 100%;
}

// headings
%h {
    margin: 0;
    font-weight: normal;
}
h1, h2, h3, h4, h5, h6 {
    @extend %h;
}
h1 {
    font-size: 22px;
    line-height: 28px;
}
h2 {
    font-size: 20px;
    line-height: 26px;
}
h3 {
    font-size: 19px;
    line-height: 24px;
}
h4 {
    font-size: 18px;
    line-height: 24px;
}
h5 {
    font-size: 17px;
    line-height: 24px;
}
h6 {
    font-size: 16px;
    line-height: 22px;
}

em {
    font-style: italic;
}

ins {
    color: var(--txtPrimaryColor);
    background: var(--successAltColor);
    text-decoration: none;
}

del {
    color: var(--txtPrimaryColor);
    background: var(--dangerAltColor);
    text-decoration: none;
}

strong {
    font-weight: 600;
}

small {
    font-size: var(--smFontSize);
    line-height: var(--smLineHeight);
}

sub,
sup {
    position: relative;
    font-size: 0.75em;
    line-height: 1;
}
sup {
    vertical-align: top;
}
sub {
    vertical-align: bottom;
}

p {
    @extend %block;
    margin: 5px 0;
}

blockquote {
    @extend %block;
    position: relative;
    padding-left: var(--smSpacing);
    font-style: italic;
    color: var(--txtHintColor);
    &:before {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        width: 2px;
        height: 100%;
        background: var(--baseColor);
    }
}

code {
    display: inline-block;
    font-family: var(--monospaceFontFamily);
    font-style: normal;
    font-size: 1em;
    line-height: 1.379rem;
    padding: 0px 4px;
    white-space: nowrap;
    color: inherit;
    background: var(--baseAlt2Color);
    border-radius: var(--baseRadius);
}

.code-block {
    @extend %block;
    overflow: auto;
    padding: var(--xsSpacing);
    white-space: pre-wrap;
    background: var(--baseAlt1Color);
}

ol,
ul {
    margin: 10px 0;
    list-style: decimal;
    padding-left: var(--baseSpacing);
    li {
        margin-top: 5px;
        margin-bottom: 5px;
    }
}
ul {
    list-style: disc;
}

img {
    max-width: 100%;
    vertical-align: top;
}

hr {
    display: block;
    border: 0;
    height: 1px;
    width: 100%;
    background: var(--baseAlt1Color);
    margin: var(--baseSpacing) 0;
    &.dark {
        background: var(--baseAlt2Color);
    }
}

a {
    color: inherit;
    &:hover {
        text-decoration: none;
    }
    i, .txt {
        display: inline-block;
        vertical-align: top;
    }
}

// text helpers
.txt-mono {
    font-family: var(--monospaceFontFamily);
}
.txt-nowrap {
    white-space: nowrap;
}
.txt-ellipsis {
    display: inline-block;
    vertical-align: top;
    flex-shrink: 1;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.txt-base {
    font-size: var(--baseFontSize) !important;
}
.txt-xs {
    font-size: var(--xsFontSize) !important;
    line-height: var(--smLineHeight);
}
.txt-sm {
    font-size: var(--smFontSize) !important;
    line-height: var(--smLineHeight);
}
.txt-lg {
    font-size: var(--lgFontSize) !important;
}
.txt-xl {
    font-size: var(--xlFontSize) !important;
}
.txt-bold {
    font-weight: 600 !important;
}
.txt-strikethrough {
    text-decoration: line-through !important;
}
.txt-break {
    white-space: pre-wrap !important;
}
.txt-center {
    text-align: center !important;
}
.txt-justify {
    text-align: justify !important;
}
.txt-left {
    text-align: left !important;
}
.txt-right {
    text-align: right !important;
}
.txt-main {
    color: var(--txtPrimaryColor) !important;
}
.txt-hint {
    color: var(--txtHintColor) !important;
}
.txt-disabled {
    color: var(--txtDisabledColor) !important;
}
.link-hint {
    user-select: none;
    cursor: pointer;
    color: var(--txtHintColor) !important;
    text-decoration: none;
    transition: color var(--baseAnimationSpeed);
    &:hover,
    &:focus-visible,
    &:active {
        color: var(--txtPrimaryColor) !important;
    }
}
.link-fade {
    opacity: 1;
    user-select: none;
    cursor: pointer;
    text-decoration: none;
    color: var(--txtPrimaryColor);
    transition: opacity var(--baseAnimationSpeed);
    &:focus-visible,
    &:hover,
    &:active {
        opacity: 0.8;
    }
}

// color helpers
@each $name, $color in $colorsMap {
    .txt-#{$name} {
        color: $color !important;
    }
    .bg-#{$name} {
        background: $color !important;
    }
    .link-#{$name} {
        cursor: pointer;
        color: $color !important;
        text-decoration: none;
        user-select: none;
        transition: opacity var(--baseAnimationSpeed);
        &:focus-visible,
        &:hover,
        &:active {
            opacity: 0.8;
        }
    }
}

.fade {
    opacity: 0.6;
}
a,
.btn,
[tabindex],
[class*="link-"],
.handle {
    &.fade {
        transition: all var(--baseAnimationSpeed);
        &:hover {
            opacity: 1;
        }
    }
}

.noborder {
    border: 0px !important;
}

.hidden {
    display: none !important;
}

.hidden-empty {
    &:empty {
        display: none !important;
    }
}

.v-align-top {
    vertical-align: top;
}
.v-align-middle {
    vertical-align: middle;
}
.v-align-bottom {
    vertical-align: bottom;
}

.scrollbar-gutter-stable {
    scrollbar-gutter: stable;
}

.no-pointer-events {
    pointer-events: none;
}

.block {
    @extend %block;
}

.content {
    @extend %block;
    min-width: 0;
    & > :first-child {
        margin-top: 0;
    }
    & > :last-child {
        margin-bottom: 0;
    }
}

.panel {
    @extend .content;
    background: var(--baseColor);
    border-radius: var(--lgRadius);
    padding: calc(var(--baseSpacing) - 5px) var(--baseSpacing);
    @include shadowize();
}

.sub-panel {
    @extend .content;
    background: var(--baseColor);
    border-radius: var(--baseRadius);
    padding: calc(var(--smSpacing) - 5px) var(--smSpacing);
    border: 1px solid var(--baseAlt1Color);
}

.shadowize {
    @include shadowize();
}

.clearfix {
    @extend %block;
    clear: both;
    &:after {
        content: '';
        display: table;
        clear: both;
    }
}

// flex helpers
.flex {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    min-width: 0;
    gap: var(--smSpacing);
}
.flex-fill {
  flex: 1 1 auto !important;
}
.flex-wrap {
    flex-wrap: wrap !important;
}
.flex-nowrap {
    flex-wrap: nowrap !important;
}
.inline-flex {
    position: relative;
    display: inline-flex;
    vertical-align: top;
    align-items: center;
    flex-wrap: wrap;
    min-width: 0;
    gap: 10px;
}
@for $i from 0 through 10 {
    .flex-order-#{$i} {
        order: $i;
    }
}

// flex gap helpers
@each $sizeAlias, $size in $sizesMap {
    .flex-gap-#{$sizeAlias} {
        gap: $size !important;
    }
}
@for $i from 0 through 12 {
    $spacing: 5 * $i;
    .flex-gap-#{$spacing} {
        gap: $spacing * 1px !important;
    }
}

// spacing helpers
@each $sizeAlias, $size in $sizesMap {
    .m-#{$sizeAlias} { margin: $size !important; }
    .p-#{$sizeAlias} { padding: $size !important; }
}
@each $sideAlias, $side in $sidesMap {
    .m-#{$sideAlias}-auto { margin-#{$side}: auto !important; }
    .p-#{$sideAlias}-auto { padding-#{$side}: auto !important; }
    @each $sizeAlias, $size in $sizesMap {
        .m-#{$sideAlias}-#{$sizeAlias} { margin-#{$side}: $size !important; }
        .p-#{$sideAlias}-#{$sizeAlias} { padding-#{$side}: $size !important; }
    }
}
@for $i from 0 through 12 {
    $spacing: 5 * $i;
    .m-#{$spacing} { margin: $spacing * 1px !important; }
    .p-#{$spacing} { padding: $spacing * 1px !important; }
    @each $sideAlias, $side in $sidesMap {
        .m-#{$sideAlias}-#{$spacing} { margin-#{$side}: $spacing * 1px !important; }
        .p-#{$sideAlias}-#{$spacing} { padding-#{$side}: $spacing * 1px !important; }
    }
}
.no-min-width {
    min-width: 0 !important;
}

.wrapper {
    position: relative;
    width: var(--wrapperWidth);
    margin: 0 auto;
    max-width: 100%;
    &.wrapper-sm {
        width: var(--smWrapperWidth);
    }
    &.wrapper-lg {
        width: var(--lgWrapperWidth);
    }
}

.label {
    --labelVPadding: 3px;
    --labelHPadding: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: top;
    gap: 5px;
    padding: var(--labelVPadding) var(--labelHPadding);
    min-height: 24px;
    max-width: 100%;
    text-align: center;
    line-height: var(--smLineHeight);
    font-size: var(--smFontSize);
    background: var(--baseAlt2Color);
    color: var(--txtPrimaryColor);
    white-space: nowrap;
    border-radius: 15px;

    .btn:last-child {
        margin-right: calc(-0.5 * var(--labelHPadding));
    }
    .btn:first-child {
        margin-left: calc(-0.5 * var(--labelHPadding));
    }

    // styles
    &.label-sm {
        --labelHPadding: 5px;
        font-size: var(--xsFontSize);
        min-height: 18px;
        line-height: 1;
    }
    &.label-primary {
        color: var(--baseColor);
        background: var(--primaryColor);
    }
    &.label-info {
        background: var(--infoAltColor);
    }
    &.label-success {
        background: var(--successAltColor);
    }
    &.label-danger {
        background: var(--dangerAltColor);
    }
    &.label-warning {
        background: var(--warningAltColor);
    }
}

.thumb {
    --thumbSize: 40px;

    display: inline-flex;
    vertical-align: top;
    position: relative;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    line-height: 1;
    width: var(--thumbSize);
    height: var(--thumbSize);
    aspect-ratio: 1;
    background: var(--baseAlt2Color);
    border-radius: var(--baseRadius);
    color: var(--txtPrimaryColor);
    outline-offset: -2px;
    outline: 2px solid transparent;
    @include shadowize();
    i {
        font-size: inherit;
    }
    img {
        width: 100%;
        height: 100%;
        border-radius: inherit;
        overflow: hidden;
    }
    &.thumb-xs {
        --thumbSize: 24px;
        font-size: 0.85rem;
    }
    &.thumb-sm {
        --thumbSize: 32px;
        font-size: 0.92rem;
    }
    &.thumb-lg {
        --thumbSize: 60px;
        font-size: 1.3rem;
    }
    &.thumb-xl {
        --thumbSize: 80px;
        font-size: 1.5rem;
    }
    &.thumb-circle {
        border-radius: 50%;
    }

    // styles
    @each $name, $color in $colorsMap {
        &.thumb-#{$name} {
            outline-color: $color;
        }
    }
}
.handle.thumb:not(.thumb-active),
a.thumb:not(.thumb-active) {
    cursor: pointer;
    transition: opacity var(--baseAnimationSpeed),
                outline-color var(--baseAnimationSpeed),
                transform var(--baseAnimationSpeed),
                box-shadow var(--baseAnimationSpeed);
    &:hover,
    &:focus-visible,
    &:active {
        opacity: 0.8;
        @include shadowize(0px 2px 4px 1px var(--shadowColor));
    }
    &:active {
        transition-duration: var(--activeAnimationSpeed);
        transform: scale(0.97);
    }
}

.section-title {
    display: flex;
    align-items: center;
    width: 100%;
    column-gap: 10px;
    row-gap: 5px;
    margin: 0 0 var(--xsSpacing);
    font-weight: 600;
    font-size: var(--baseFontSize);
    line-height: var(--smLineHeight);
    color: var(--txtHintColor);
}

.logo {
    position: relative;
    vertical-align: top;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 23px;
    text-decoration: none;
    color: inherit;
    user-select: none;
    strong {
        font-weight: bold;
    }
    .version {
        position: absolute;
        right: 0;
        top: -5px;
        line-height: 1;
        font-size: 10px;
        font-weight: normal;
        padding: 2px 4px;
        border-radius: var(--baseRadius);
        background: var(--dangerAltColor);
        color: var(--txtPrimaryColor);
    }

    &.logo-sm {
        font-size: 20px;
    }
}

.drag-handle {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex-shrink: 0;
    color: var(--txtDisabledColor);
    user-select: none;
    cursor: pointer;
    transition: color var(--baseAnimationSpeed),
                transform var(--baseAnimationSpeed),
                opacity var(--baseAnimationSpeed),
                visibility var(--baseAnimationSpeed);
    &:before{
        content: "\ef77";
        line-height: 1;
        font-family: var(--iconFontFamily);
        padding-right: 5px;
        text-shadow: 5px 0px currentColor;
    }
    &:hover,
    &:focus-visible {
        color: var(--txtHintColor);
    }
    &:active {
        transition-duration: var(--activeAnimationSpeed);
        color: var(--txtPrimaryColor);
    }
}

.loader {
    --loaderSize: 32px;

    position: relative;
    display: inline-flex;
    vertical-align: top;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    row-gap: 10px;
    margin: 0;
    color: var(--txtDisabledColor);
    text-align: center;
    font-weight: normal;
    &:before {
        content: "\eec4";
        display: inline-block;
        vertical-align: top;
        clear: both;
        width: var(--loaderSize);
        height: var(--loaderSize);
        line-height: var(--loaderSize);
        font-size: var(--loaderSize);
        font-weight: normal;
        font-family: var(--iconFontFamily);
        color: inherit;
        text-align: center;
        animation: loaderShow var(--activeAnimationSpeed),
                   rotate 0.9s var(--baseAnimationSpeed) infinite linear;
    }

    // styles
    @each $name, $color in $colorsMap {
        &.loader-#{$name} {
            color: $color;
        }
    }

    // sizes
    &.loader-xs {
        --loaderSize: 18px;
    }
    &.loader-sm {
        --loaderSize: 24px;
    }
    &.loader-lg {
        --loaderSize: 42px;
    }
}

.skeleton-loader {
    @extend %block;
    position: relative;
    height: 12px;
    margin: 5px 0;
    border-radius: var(--baseRadius);
    background: var(--baseAlt1Color);
    animation: fadeIn 0.4s;
    &:before {
        content: "";
        width: 100%;
        height: 100%;
        display: block;
        border-radius: inherit;
        background: linear-gradient(90deg, var(--baseAlt1Color) 8%, var(--bodyColor) 18%, var(--baseAlt1Color) 33%);
        background-size: 200% 100%;
        animation: shine 1s linear infinite;
    }
}

.placeholder-section {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex-direction: column;
    gap: var(--smSpacing);
    color: var(--txtHintColor);
    .icon {
        $size: 50px;
        font-size: $size;
        height: $size;
        line-height: 1;
        opacity: 0.3;
        i {
            font-size: inherit;
            vertical-align: top;
        }
    }
}

.list {
    @extend %block;
    position: relative;
    overflow: auto; /* fallback */
    overflow: overlay;
    border: 1px solid var(--baseAlt2Color);
    border-radius: var(--baseRadius);
    .list-item {
        word-break: break-word;
        position: relative;
        display: flex;
        align-items: center;
        width: 100%;
        gap: var(--xsSpacing);
        outline: 0;
        padding: 10px var(--xsSpacing);
        min-height: 50px;
        border-top: 1px solid var(--baseAlt2Color);
        transition: background var(--baseAnimationSpeed);
        &:first-child {
            border-top: 0;
        }
        &:last-child {
            border-bottom-left-radius: inherit;
            border-bottom-right-radius: inherit;
        }
        .content {
            display: flex;
            align-items: center;
            gap: 5px;
            min-width: 0;
            max-width: 100%;
            user-select: text;
        }
        .actions {
            margin-left: auto;
            gap: 10px;
            flex-shrink: 0;
            display: inline-flex;
            align-items: center;
            margin: -1px -5px -1px 0;
            &.nonintrusive {
                opacity: 0;
                transform: translateX(5px);
                transition: transform var(--baseAnimationSpeed),
                            opacity var(--baseAnimationSpeed),
                            visibility var(--baseAnimationSpeed);
            }
        }
        &:hover,
        &:focus-visible,
        &:focus-within,
        &:active {
            background: var(--bodyColor);
            .actions.nonintrusive {
                opacity: 1;
                transform: translateX(0);
            }
        }
        // styles
        &.selected {
            background: var(--bodyColor);
        }
        &.handle:not(.disabled) {
            cursor: pointer;
            user-select: none;
            &:hover,
            &:focus-visible {
                background: var(--baseAlt1Color);
            }
            &:active {
                background: var(--baseAlt2Color);
            }
        }
        &.disabled:not(.selected) {
            cursor: default;
            opacity: 0.6;
        }
    }

    .list-item-placeholder {
        color: var(--txtHintColor);
    }

    .list-item-btn {
        padding: 5px;
        min-height: auto;
    }

    .list-item-placeholder,
    .list-item-btn {
        &:hover,
        &:focus-visible,
        &:focus-within,
        &:active {
            background: none;
        }
    }

    &.list-compact {
        .list-item {
            gap: 10px;
            min-height: 40px;
        }
    }
}

// base entrance animations
.entrance-top {
    animation: entranceTop var(--entranceAnimationSpeed);
}
.entrance-bottom {
    animation: entranceBottom var(--entranceAnimationSpeed);
}
.entrance-left {
    animation: entranceLeft var(--entranceAnimationSpeed);
}
.entrance-right {
    animation: entranceRight var(--entranceAnimationSpeed);
}
.entrance-fade {
    animation: fadeIn var(--entranceAnimationSpeed);
}

.provider-logo {
    $boxSize: 32px;
    $imgSize: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: $boxSize;
    height: $boxSize;
    border-radius: var(--baseRadius);
    background: var(--bodyColor);
    padding: 0;
    gap: 0;
    img {
        max-width: $imgSize;
        max-height: $imgSize;
        height: auto;
        flex-shrink: 0;
    }
}
.provider-card {
    display: flex;
    align-items: center;
    width: 100%;
    height: 100%;
    gap: 10px;
    padding: 10px;
    border-radius: var(--baseRadius);
    border: 1px solid var(--baseAlt1Color);
}

// sidebar menu
.sidebar-menu {
    --sidebarListItemMargin: 10px;

    z-index: 0;
    display: flex;
    flex-direction: column;
    width: 200px;
    flex-shrink: 0;
    flex-grow: 0;
    overflow-x: hidden;
    overflow-y: auto;
    background: var(--baseColor);
    padding: calc(var(--baseSpacing) - 5px) 0 var(--smSpacing);
    & > * {
        padding: 0 var(--smSpacing);
    }
    .sidebar-content {
        overflow-x: hidden;
        overflow-y: auto; /* fallback */
        overflow-y: overlay;
        & > :first-child {
            margin-top: 0;
        }
        & > :last-child {
            margin-bottom: 0;
        }
    }
    .sidebar-footer {
        margin-top: var(--smSpacing);
    }
    .search {
        display: flex;
        align-items: center;
        width: auto;
        column-gap: 5px;
        margin: 0 0 var(--xsSpacing);
        color: var(--txtHintColor);
        opacity: 0.7;
        transition: opacity var(--baseAnimationSpeed),
                    color var(--baseAnimationSpeed);
        input {
            border: 0;
            background: var(--baseColor);
            transition: box-shadow var(--baseAnimationSpeed),
                        background var(--baseAnimationSpeed);
        }
        .btn-clear {
            margin-right: -8px;
        }
        &:hover,
        &:focus-within,
        &.active {
            opacity: 1;
            color: var(--txtPrimaryColor);
            input {
                background: var(--baseAlt2Color);
            }
        }
    }
    .sidebar-title {
        display: flex;
        align-items: center;
        gap: 5px;
        width: 100%;
        margin: var(--baseSpacing) 0 var(--xsSpacing);
        font-weight: 600;
        font-size: 1rem;
        line-height: var(--smLineHeight);
        color: var(--txtHintColor);
        .label {
            font-weight: normal;
        }
    }
    .sidebar-list-item {
        cursor: pointer;
        outline: 0;
        text-decoration: none;
        position: relative;
        display: flex;
        width: 100%;
        align-items: center;
        column-gap: 10px;
        margin: var(--sidebarListItemMargin) 0;
        padding: 3px 10px;
        font-size: var(--xlFontSize);
        min-height: var(--btnHeight);
        min-width: 0;
        color: var(--txtHintColor);
        border-radius: var(--baseRadius);
        user-select: none;
        transition: background var(--baseAnimationSpeed),
                    color var(--baseAnimationSpeed);
        i {
            font-size: 18px;
        }
        .txt {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        // states
        &:focus-visible,
        &:hover,
        &:active,
        &.active {
            color: var(--txtPrimaryColor);
            background: var(--baseAlt1Color);
        }
        &:active {
            background: var(--baseAlt2Color);
            transition-duration: var(--activeAnimationSpeed);
        }
    }
    .sidebar-content-compact .sidebar-list-item {
        --sidebarListItemMargin: 5px;
    }

    // responsive
    @media screen and (max-height: 600px) {
        --sidebarListItemMargin: 5px;
    }
    @media screen and (max-width: 1100px) {
        min-width: 190px;
        & > * {
            padding-left: 10px;
            padding-right: 10px;
        }
    }
}
